<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue-2.5.js"></script>
</head>
<body>
    <div id="app">
        <component :is="currentView"></component>
        <button @click="change('A')">A</button>
        <button @click="change('B')">B</button>
    </div>
    <script>
        let app = new Vue({
            el:'#app',
            components:{
                comA:{
                    template:'<div>组件A</div>'
                },
                comB:{
                    template:'<div>组件B</div>'
                },
            },
            data:{
            currentView:'comA'
            },
            methods: {
                change:function(pre){
                    console.log('pre :', pre);
                    this.currentView = 'com'+pre;
                }
            },
        })
        
    
        
    </script>
</body>
</html>